﻿<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>

<? foreach($arResult as $item): ?>

<div class="date"><?= $item["DATE"]; ?></div>
<div class="lec"><?= $item["NAME"]; ?></div>
<div class="author">
    <div class="foto"><?= CFile::ShowImage($item["LECTOR_FOTO"], 40, 40); ?></div>
    <?= $item["LECTOR"]; ?><div class="h5"></div><?/*= $item["LECTOR_DEPARTMENT"]; ?>, <?= $item["LECTOR_POSITION"]; */?>
</div>
<div class="spacer h5"></div>
<div class="placeandtime"><?= $item["PROPERTY_PLACE_VALUE"]; ?> в <?= $item["TIME"]; ?></div>
<div class="spacer h5"></div>
<div class="desc"><?= $item["PREVIEW_TEXT"]; ?></div>
<div class="button">
    <? if ($item["CAN_SIGNUP"]): ?>
    <form action="<?= $APPLICATION->GetCurPage(); ?>" method="POST">
        <input type="hidden" name="FORMTYPE" value="signup" />
        <input type="hidden" name="LECTURE_ID" value="<?= $item["ID"]; ?>" />
        <input type="submit" value="Записаться" />
    </form>
    <? elseif ($item["CAN_REJECT"]): ?>
    <form action="<?= $APPLICATION->GetCurPage(); ?>" method="POST">
        <input type="hidden" name="FORMTYPE" value="reject" />
        <input type="hidden" name="LECTURE_ID" value="<?= $item["ID"]; ?>" />
        <input type="hidden" name="RECORD_ID" value="<?= $item["CAN_REJECT"]; ?>" />
        <input type="submit" value="Отказаться" />
    </form>    
    <? endif; ?>    
</div>

<? if ($cnt = count($item["AUDIENCE"])):?>
<div class="zag"><a href="#" onclick="change('l<?= $item["ID"]; ?>'); return false;">Слушатели (<?= $cnt; ?>)</a></div>
<div class="audience" id="l<?= $item["ID"]; ?>">
    <? $n = 0; ?>
    <? foreach($item["AUDIENCE"] as $user): ?>
        <? if ($n++) echo ", "; ?>
        <?= $user["LISTENER"]; ?>
    <? endforeach; ?>
</div>
 <? endif; ?>    

<div class="h40"></div>

<? endforeach; ?>

<script>
function change(el)
{
    el = document.getElementById(el);
    curr_shown = el.style.display == "block";
    el.style.display = (curr_shown) ? "none" : "block";    
}
</script>    